package lanou3g.myfirstapp36kr.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;

import java.util.ArrayList;
import java.util.List;

import lanou3g.myfirstapp36kr.R;
import lanou3g.myfirstapp36kr.adapter.LoginAdapter;
import lanou3g.myfirstapp36kr.base.BaseActivity;
import lanou3g.myfirstapp36kr.fragment.LoginFragment;
import lanou3g.myfirstapp36kr.fragment.RigistFragment;

/**
 * Created by dllo on 16/8/29.
 */
public class LoginActivity extends BaseActivity {
    private List<Fragment> fragments;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private LoginAdapter adapter;
    @Override
    protected int getLayout() {
        return R.layout.activity_login;
    }

    @Override
    protected void initView() {
        findViewById(R.id.iv_finish).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        tabLayout = (TabLayout) findViewById(R.id.tab_login);
        viewPager = (ViewPager) findViewById(R.id.viewpager_login);
        fragments = new ArrayList<>();


    }

    @Override
    protected void initData() {
        fragments.add(new LoginFragment());
        fragments.add(new RigistFragment());
        tabLayout.setupWithViewPager(viewPager);
        adapter = new LoginAdapter(getSupportFragmentManager(),fragments);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

    }

}
